﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>联系方式信息</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="../../../js/jquery/boot.js" type="text/javascript"></script>
<style type="text/css">
html,body {
	font-size: 12px;
	padding: 0;
	margin: 0;
	border: 0;
	height: 100%;
	overflow: hidden;
}
</style>
</head>
<body>

<form id="form1" method="post"><input name="id"
	class="mini-hidden" />
<div style="padding-left: 11px; padding-bottom: 5px;">
<table style="table-layout: fixed;">
	<tr>
		<td style="width: 160px;">联系电话（多个以;分开）：</td>
		<td style="width: 160px;"><input name="telephone" class="mini-textbox" required="true" /></td>
		<td style="width: 100px;">联系人姓名：</td>
		<td style="width: 200px;"><input name="name" class="mini-textbox" required="true" /></td>
	</tr>
	<tr>
		<td>传真（多个以;分开）：</td>
		<td><input name="fax" class="mini-textbox" required="true"/></td>
		<td>邮编：</td>
		<td><input name="postalCode" class="mini-textbox" required="true" vtype="int"/></td>
	</tr>
	<tr>
		<td>在线QQ（多个以;分开）：</td>
		<td><input name="onlineQq" class="mini-textbox" required="true"/></td>
		<td>联系地址：</td>
		<td><input name="address" class="mini-textbox" required="true"/></td>
	</tr>
	<tr>
		<td>手机号码（多个以;分开）：</td>
		<td><input name="phoneNumber" class="mini-textbox" required="true"/></td>
		<td>备注：</td>
		<td><input name="memo" class="mini-textarea" /></td>
	</tr>
</table>
</div>
<div style="text-align: center; padding: 10px;">
	<a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a> 
	<a class="mini-button" onclick="onCancel" style="width: 60px;">取消</a>
</div>
</form>
<script type="text/javascript">
        mini.parse();

        var form = new mini.Form("form1");

        function SaveData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode(o);
            $.ajax({
                url: "../../../contact/create.jsps",
                data: { contact : json },
                cache: false,
                success: function (text) {
                	if (text == "" || typeof(text) == 'object') {
                    	CloseWindow("save");
                	} else {
                		var error = mini.decode(text);
                		mini.alert(error.error);
                   	}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                	mini.alert(jqXHR.responseText);
                }
            });
        }

        function UpdateData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode(o);
            $.ajax({
                url: "../../../contact/update.jsps",
                data: { contact : json },
                cache: false,
                success: function (text) {
                	if (text == "" || typeof(text) == 'object') {
                    	CloseWindow("save");
                	} else {
                		var error = mini.decode(text);
                		mini.alert(error.error);
                   	}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                	mini.alert(jqXHR.responseText);
                }
            });
        }

        ////////////////////
        //标准方法接口定义
        var isEdit = false;
        function SetData(data) {
            if (data.action == "edit") {
                isEdit = true;
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                $.ajax({
                    url: "../../../contact/read.jsps",
                    data: { id: data.id },
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                    }
                });
            }
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {            
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk(e) {
            if (!isEdit) {
            	SaveData();
            } else {
				UpdateData();
            }
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
</body>
</html>
